package com.yydream.common.utils;


import com.yydream.common.constant.HttpStatus;
import com.yydream.vo.ResultVo;

/**
 * 返回数据
 */
public class R extends ResultVo {
	private static final long serialVersionUID = 1L;

	public R() {

	}
	
	public static R error() {
		return error(HttpStatus.SYSTEM_ERROR.getCode(), HttpStatus.SYSTEM_ERROR.getMsg());
	}
	
	public static R error(String msg) {
		return error(HttpStatus.SYSTEM_ERROR.getCode(), msg);
	}

	public static R error (HttpStatus status) {
		return error(status.getCode(), status.getMsg());
	}
	
	public static R error(Integer code, String msg) {
		R r = new R();
		r.setCode(code);
		r.setMsg(msg);
		r.setSuccess(false);
		return r;
	}

	public static R ok(String msg) {
		R r = new R();
		r.setCode(HttpStatus.SUCCESS.getCode());
		r.setSuccess(true);
		r.setMsg(msg);
		return r;
	}

	public static R ok() {
		R r = new R();
		r.setCode(HttpStatus.SUCCESS.getCode());
		r.setMsg(HttpStatus.SUCCESS.getMsg());
		r.setSuccess(true);
		return r;
	}

	public R put(Object value) {
		this.setData(value);
		return this;
	}
}
